using UnityEngine;

[ExecuteInEditMode]
public class HealthBar3D : MonoBehaviour
{
	public float _percent = 1f;

	public GameObject BG;

	public GameObject FG;

	public MeshRenderer helathBar;

	public MeshRenderer backGround;

	public float percent
	{
		get
		{
			return _percent;
		}
		set
		{
			_percent = Mathf.Clamp01(value);
		}
	}

	private void Update()
	{
		FG.transform.localScale = new Vector3(BG.transform.localScale.x * percent, BG.transform.localScale.y, BG.transform.localScale.z);
		FG.transform.localPosition = new Vector3(BG.transform.localPosition.x + BG.transform.localScale.x / 2f * percent - BG.transform.localScale.x / 2f, BG.transform.localPosition.y, BG.transform.localPosition.z);
	}
}
